package com.mindskip.xzs.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.domain.VideoUser;
import com.mindskip.xzs.repository.BaseMapper;
import com.mindskip.xzs.repository.VideoUserMapper;
import com.mindskip.xzs.service.VideoUserService;
import com.mindskip.xzs.viewmodel.admin.education.VideoPageRequestVM;
import com.mindskip.xzs.viewmodel.admin.education.VideoUserPageRequestVM;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author changjiang
 * @Title:
 * @Package
 * @Description: 视频
 * @date 2022/1/209:27 下午
 */

@Service
public class VideoUserServiceImpl extends BaseServiceImpl<VideoUser> implements VideoUserService {

    private final VideoUserMapper videoUserMapper;

    public VideoUserServiceImpl(VideoUserMapper videoUserMapper, BaseMapper<VideoUser> baseMapper) {
        super(baseMapper);
        this.videoUserMapper = videoUserMapper;
    }


    @Override
    public List<VideoUser> getVideoUserList(VideoUser videoUser) {
        return videoUserMapper.getVideoUserList(videoUser);
    }

    @Override
    public VideoUser getForUserIdAndVideoId(VideoUser videoUser) {
        return videoUserMapper.getForUserIdAndVideoId(videoUser);
    }

    @Override
    public PageInfo<VideoUser> getVideoUserListPage(VideoUserPageRequestVM requestVM) {

        String orderBy = "update_time desc";
        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), orderBy).doSelectPageInfo(() ->
                videoUserMapper.getVideoUserListPage(requestVM)
        );
    }

    @Override
    public int countTime(VideoUser videoUser) {
        return videoUserMapper.countTime(videoUser);
    }

    @Override
    public int countTimeVideo(VideoUser videoUser) {
        return videoUserMapper.countTimeVideo(videoUser);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return videoUserMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(VideoUser videoUser) {
        return videoUserMapper.insertSelective(videoUser);
    }

    @Override
    public int updateByPrimaryKeySelective(VideoUser videoUser) {
        return videoUserMapper.updateByPrimaryKeySelective(videoUser);
    }

    @Override
    public int updateByPrimaryKey(VideoUser videoUser) {
        return videoUserMapper.updateByPrimaryKey(videoUser);
    }

    @Override
    public List<VideoUser> getVideoUserListForUid(VideoUser videoUser) {
        return videoUserMapper.getVideoUserListForUid(videoUser);
    }
}
